package cn.kgm.nio;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class NioFileChanalCopyImage {
    private final static String nioUrl = "niofile/";

    public static void main(String[] args) throws Exception {
        File image = new File(nioUrl+"dino.jpg");
        File copyImage = new File(nioUrl+"copyDino.jpg");
        FileInputStream inputStream = new FileInputStream(image);
        FileOutputStream outputStream = new FileOutputStream(copyImage);

        FileChannel input = inputStream.getChannel();
        FileChannel output = outputStream.getChannel();

//        input.transferTo(0,image.length(),output);
        output.transferFrom(input,0,image.length());

        inputStream.close();
        outputStream.close();
    }
}
